package generics;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 10.05.11
 * Time: 16:23
 * To change this template use File | Settings | File Templates.
 */
public class GenericCollections {


	public void collectionsGeneric() {

		List<String> string_list = new LinkedList<String>();

		string_list.add("Achtung");
		string_list.add("Prague");
//        string_list.add(new Integer(2));


		String first_value = string_list.get(0);

		System.out.println("First value is "+first_value);

		String operate_string;
		for(String value: string_list) {
			operate_string = value.substring(0,2);
			System.out.println(operate_string);
		}


	}

	public void collectionsNonGeneric() {

		List string_list = new LinkedList();

		string_list.add("Achtung");
		string_list.add("Prague");
        string_list.add(new Integer(2));


		String first_value = (String) string_list.get(0);

		System.out.println("First value is "+first_value);

		String operate_value;
		String value_string;
		for(Object value_object: string_list) {
			value_string = (String) value_object;
			operate_value = value_string.substring(0,2);
			System.out.println(operate_value);
		}
	}

}
